<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/page/public/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>审批管理</title>
<% request.setAttribute("menu", 1); %>
<%@ include file="/WEB-INF/page/public/contentmeta.jsp"%>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="<%=basePath%>css/global.css" media="all" />
<link rel="stylesheet" href="<%=basePath%>plugins/font-awesome/css/font-awesome.min.css"/>
<link rel="stylesheet" href="<%=basePath%>css/system.css" media="all"/>
<link rel="stylesheet" href="<%=basePath%>css/tab.css" media="all" />
<style type="text/css">

/* 收款弹窗 */
.collection-money { display:none; }




</style>
</head>
<body>

<div class="admin-tab admin-user">
    <div class="tab-condition">
        <form class="layui-form clefix" id="htform" action="/workmanage/approvelisturl" method="post">
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="text" name="keyWord" id="keyWord"  autocomplete="off" placeholder="请输入关键字" class="layui-input" value="${pager.params.KeyWord }">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block" style="width:170px;">
                	<select name="state" id="state"  lay-filter="state" value="${pager.params.state}" >
		            	<dic:cf value="${pager.params.state}" name="approve_state" type="2"/>
		            </select>
                </div>
            </div>
            <div class="layui-form-item">
	            <input name="skipToPage" id="skipToPage"  type="hidden" value="${pager.pageNo}">
				<input type="hidden" id="pageNo" name="pageNo" value="${pager.pageNo}">
				<input type="hidden" id="totalPage" name="totalPage" value="${pager.totalPages}">
                <button class="layui-btn TM-btn-search searchbtn" lay-submit="" lay-filter="demo2"><i class="layui-icon layui-unselect layui-tab-close">&#xe615;</i>搜索</button>
               <button class="layui-btn refreshbtn"  type="button"><i class="layui-icon layui-unselect layui-tab-close ">&#x1002;</i>刷新</button>  
            </div>
        </form>
    </div>
    <div class="layui-field-box">
        <table class="site-table table-hover TM-table-news">
            <thead>
            <tr>
                <th style="width:5%;">编号</th>
                <th style="width:20%;">审批标题</th>
                <th style="width:10%;">发起人</th>
                <th style="width:10%;">部门</th>
                <th style="width:10%;">联系电话</th>
                <th style="width:10%;">申请时间</th>
                 <th style="width:5%;">状态</th>
                  <th style="width:5%;">类型</th>
                <th style="width:25%;">操作</th>
            </tr>
            </thead>
            <tbody>
	            <c:forEach var="obj" items="${pager.resultList}" varStatus="o1">
		            <tr>
			                <td>${o1.index+1}</td>
			                <td>${obj.name}</td>
			                <td>${obj.userInfo.name}</td>
			                <td> <dic:dp value="${obj.userInfo.deptid}" type="1"/></td>
			                <td>${obj.userInfo.phone}</td>
			                <td>${obj.createdate.substring(0,10)}</td>
			                <td><dic:cf value="${obj.state}" name="approve_state" type="1"/></td>
			                <td><dic:cf value="${obj.type}" name="approve_type" type="1"/></td>
			                <td>	<a class="layui-btn layui-btn-normal layui-btn-mini  showinfo" data="${obj.id}" dataurl="${obj.url}" dstate="${obj.state}"   type="button">查看</a></td>
		            </tr>
	            </c:forEach> 
	           
            </tbody>
        </table>
        <div class="admin-table-page">
            <div id="page" class="page"></div>
        </div>	
    </div>
</div>
 

    <!-- 驳回弹窗 -->
    <div class="layui-form approve"  style="display:none">
			<div class="TM-booking-to" style="padding:10px 20px;">
    			<div class="layui-form-item">
					<label class="layui-form-label">驳回理由：</label>
				    <div class="layui-input-block" style="width:60%">
				      	<textarea name="remark" id="bhly" placeholder="请输入内容" class="layui-textarea"></textarea>
				    </div>
			    </div>
			</div>
    </div>
    
     <!-- 通过弹窗 -->
    <div class="layui-form approveagree"  style="display:none">
			<div class="TM-booking-to" style="padding:10px 20px;">
    			<div class="layui-form-item">
					<label class="layui-form-label">备注：</label>
				    <div class="layui-input-block" style="width:60%">
				      	<textarea name="remark" id="tgbz" placeholder="请输入内容" class="layui-textarea"></textarea>
				    </div>
			    </div>
			</div>
    </div>

<script>
    layui.config({
        base: 'plugins/layui/modules/'
    });
    layui.use(['element','laypage','form','laydate','layer'], function() {
        var $ = layui.jquery,
                laypage = layui.laypage,
                layer = layui.layer,
                element = layui.element(); //Tab的切换功能，切换事件监听等，需要依赖element模块
        var form = layui.form();
                
        //更新渲染
        form.render();
         
 
        
        //查看详情
        $('.showinfo').on('click',function(){
        	var id =  $(this).attr("data"),url =  $(this).attr("dataurl"),state = $(this).attr("dstate");
        	//不为审批状态时 显示详情内容
        	if(state!=1){
        		  parent.layer.open({
                      title:'内容详情',
                      type:2,
                      content:url,
                      shadeClose:true,
                      btnAlign:'c',
                      area:['80%','90%']
        		  })
        		  
        		  return false;
        	}
        	
            parent.layer.open({
                title:'内容详情',
                type:2,
                content:url,
                shadeClose:true,
                btnAlign:'c',
                btn:['通过','驳回'], 
                area:['80%','90%'],
                yes: function(layero, index){ 
                	parent.layer.closeAll();
                	 layer.open({
         	   		  	type:1,
         	   		  	btn:['确定通过','取消'],
         	           	btnAlign:'c',
         	           	shadeClose:true,
         		  		title:"审批通过",
         		  		content: $(".approveagree"),
         		  		area:['50%','350px'],
         		  		maxWidth:800,
         		  		yes: function(layero, index){
         		  			var remark = $("#tgbz").val();
         		  			layer.closeAll();
                        	$.ajax({
                				type : "post",
                				url : "/workmanage/approveagree",
                				data : {id:id,state:2,remark:remark},
                				dataType : "json",
                				async : false ,
                				success : function(data){
                					if(data=="1"){
                						parent.layer.msg("审批成功",{icon: 1},function(){
                    						window.location.reload();
                    					});
                					}else{
                						parent.layer.msg("审批失败",{icon: 2} );
                					} 
                				}
                			});
                        }
               		});  
                	
                },btn2:function(){
                	 layer.open({
        	   		  	type:1,
        	   		  	btn:['确定驳回','取消'],
        	           	btnAlign:'c',
        	           	shadeClose:true,
        		  		title:"审批驳回",
        		  		content: $(".approve"),
        		  		area:['50%','350px'],
        		  		maxWidth:800,
        		  		yes: function(layero, index){
        		  			var remark = $("#bhly").val();
        		  			layer.closeAll();
        		  			$.ajax({
                				type : "post",
                				url : "/workmanage/approveagree",
                				data : {id:id,state:3,remark:remark},
                				dataType : "json",
                				async : false ,
                				success : function(data){
                					if(data==1){
                						layer.msg("已成功驳回",{icon:1},function(){
                    						window.location.reload();
                    					});
                					}else{
                						layer.msg("驳回失败",{icon:2} );
                					} 
                				
                				}
                			});
                       }
              		}); 
                	 
                 
                },cancel: function(){ 
                     
                
                 }
            });
        });
        
       
        $(".searchbtn").on("click",function(){
        	$("#skipToPage").val(1);
  			form.submit();
        });
        
        //page
        laypage({
            cont: 'page',
            curr: "${pager.pageNo}",
            pages: "${pager.totalPages}" //总页数
            ,
            groups: 5 //连续显示分页数
            ,
            jump: function(obj, first) {
                //得到了当前页，用于向服务端请求对应数据
                var curr = obj.curr;
                if(!first) {
                	$("#skipToPage").val(curr);
                	$("#htform").submit();
                }
            }
        });
    });
</script>


</body>
</html>